package my;

import my.dao.ItemsDao;
import my.domain.Items;
import my.service.ItemsService;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class test {
    @Test
    public void test01(){
        ClassPathXmlApplicationContext con = new ClassPathXmlApplicationContext("applicationContext.xml");
        ItemsDao dao = con.getBean(ItemsDao.class);
        List<Items> list = dao.findAll();
        for (Items items : list) {
            System.out.println(items);
        }
    }

    @Test
    public void test02(){
        ClassPathXmlApplicationContext con = new ClassPathXmlApplicationContext("applicationContext.xml");
        ItemsDao dao = con.getBean(ItemsDao.class);
        Items items = dao.findById(2);
        System.out.println(items);
    }

    @Test
    public void test03(){
        ClassPathXmlApplicationContext con = new ClassPathXmlApplicationContext("applicationContext.xml");
        ItemsService service = con.getBean(ItemsService.class);
        List<Items> list = service.findAll();
        for (Items items : list) {
            System.out.println(items);
        }
    }

    @Test
    public void test04(){
        ClassPathXmlApplicationContext con = new ClassPathXmlApplicationContext("applicationContext.xml");
        ItemsService service = con.getBean(ItemsService.class);
        Items items = service.findById(2);
        System.out.println(items);

    }



}
